package com.oocl.userinfo.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.oocl.userinfo.dao.UserDao;
import com.oocl.userinfo.dao.impl.UserDaoImpl;
import com.oocl.userinfo.util.HTMLUtil;

public class AllUsersServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	
	private UserDao userDao;
	
	public AllUsersServlet() {
		userDao = new UserDaoImpl();
	}
       
	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		response.setHeader("Content-Type", "text/html;charset=utf-8");
		PrintWriter writer = response.getWriter();
		HTMLUtil.writeAllUsersHTML(userDao.findAll(), writer);
		writer.close();
	}

	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
